package com.dwxt.cdms.controller;

import com.dwxt.cdms.service.WatchService;
import com.dwxt.cdms.service.YuMengService;
import com.dwxt.cdms.view.wristwatch.*;
import com.dwxt.cdms.vo.SelectLocDataVo;
import com.dwxt.cdms.vo.SelectWatchDataVo;
import com.dwxt.cdms.vo.SelectWatchVo;
import com.dwxt.common.base.BaseResult;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 翎盟 健康数据
 *
 * @author Kuang.JiaZhuo
 * @date 2020-09-08 11:57
 */
@RestController
@RequestMapping({ "/cdms/parse" })
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YuMengController {

    private final YuMengService yuMengService;
    private final WatchService watchService;


    /**
     * @方法名：receiveData
     * @描述： 解析 翎盟 健康数据
     * @作者： kjz
     * @日期： Created in 2020/9/8 14:05
     */
    @RequestMapping("/receiveData")
    public BaseResult receiveData(HttpServletRequest request) {

        return BaseResult.ok(yuMengService.receiveData(request));
    }

    /**
     * @方法名：pageStepDataViewList
     * @描述： 查询-腕表计步数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 14:30
     */
    @RequestMapping("/pageStepDataViewList")
    public BaseResult pageStepDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<StepDataView> pageInfo = watchService.pageStepDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：pageStepDataViewListByCustomerId
     * @描述： 按客户id查询腕表计步数据(带分页)
     * @作者： kjz
     * @日期： Created in 2020/10/12 15:06
     */
    @RequestMapping("/pageStepDataViewListByCustomerId")
    public BaseResult pageStepDataViewListByCustomerId(SelectWatchVo selectWatchVo){
        PageInfo<StepDataView> pageInfo = watchService.pageStepDataViewListByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：pageSleepDataViewList
     * @描述： 查询-腕表睡眠数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 16:26
     */
    @RequestMapping("/pageSleepDataViewList")
    public BaseResult pageSleepDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<SleepDataView> pageInfo = watchService.pageSleepDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：selectSleepDataViewByCondition
     * @描述： 查询-腕表睡眠数据-带分页(亮哥修改的新原型)
     * @作者： kjz
     * @日期： Created in 2020/9/12 17:56
     */
    @RequestMapping("/selectSleepDataViewByCondition")
    public BaseResult selectSleepDataViewByCondition(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<NewSleepDataView> pageInfo = watchService.selectSleepDataViewByCondition(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：selectSleepDataViewByCustomerId
     * @描述： 传入客户id 查询腕表睡眠数据
     * @作者： kjz
     * @日期： Created in 2020/10/12 16:06
     */
    @RequestMapping("/selectSleepDataViewByCustomerId")
    public BaseResult selectSleepDataViewByCustomerId(SelectWatchVo selectWatchVo) {
        PageInfo<NewSleepDataView> pageInfo = watchService.selectSleepDataViewByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @Description: TV单个用户睡眠曲线数据
     * @param customerId:
     * @param scope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/19
     */
    @RequestMapping("/selectCustomerSleepDataView")
    public BaseResult selectCustomerSleepDataView(@RequestParam(required = true) String customerId,
                                                  @RequestParam(required = true,defaultValue = "1")Integer scope) {
        return  BaseResult.ok(watchService.selectCustomerSleepDataView(customerId,scope));
    }

    /**
     * @方法名：pageHrDataViewList
     * @描述： 查询-腕表心率数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 16:50
     */
    @RequestMapping("/pageHrDataViewList")
    public BaseResult pageHrDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<HrDataView> pageInfo = watchService.pageHrDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：pageHrDataViewListByCustomerId
     * @描述： 按客户id查询腕表心率列表
     * @作者： kjz
     * @日期： Created in 2020/10/12 16:34
     */
    @RequestMapping("/pageHrDataViewListByCustomerId")
    public BaseResult pageHrDataViewListByCustomerId(SelectWatchVo selectWatchVo) {
        PageInfo<HrDataView> pageInfo = watchService.pageHrDataViewListByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @Description: TV获取单个用户心率曲线数据
     * @param customerId:
     * @param scope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/20
     */
    @RequestMapping("/selectCustomerHrDataView")
    public BaseResult selectCustomerHrDataView(@RequestParam(required = true) String customerId,
                                               @RequestParam(required = true,defaultValue = "1")Integer scope) {
        return  BaseResult.ok(watchService.selectCustomerHrDataView(customerId,scope));
    }



    /**
     * @方法名：pageBpDataViewList
     * @描述： 查询-腕表血压数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 17:09
     */
    @RequestMapping("/pageBpDataViewList")
    public BaseResult pageBpDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<BpDataView> pageInfo = watchService.pageBpDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：pageBpDataViewListByCustomerId
     * @描述： 按客户id查询腕表血压数据(带分页)
     * @作者： kjz
     * @日期： Created in 2020/10/12 17:19
     */
    @RequestMapping("/pageBpDataViewListByCustomerId")
    public BaseResult pageBpDataViewListByCustomerId(SelectWatchVo selectWatchVo) {
        PageInfo<BpDataView> pageInfo = watchService.pageBpDataViewListByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }
    /**
     * @Description: TV获取单个用户血压曲线数据
     * @param customerId: 
     * @param scope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/20       
     */  
    @RequestMapping("/selectCustomerBpDataView")
    public BaseResult selectCustomerBpDataView(@RequestParam(required = true) String customerId,
                                               @RequestParam(required = true,defaultValue = "1")Integer scope) {
        return  BaseResult.ok(watchService.selectCustomerBpDataView(customerId,scope));
    }

    /**
     * @方法名：pageBtDataViewList
     * @描述： 查询-腕表体温数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 17:40
     */
    @RequestMapping("/pageBtDataViewList")
    public BaseResult pageBtDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<BtDataView> pageInfo = watchService.pageBtDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：pageBtDataViewListByCustomerId
     * @描述： 根据用户id查询腕表体温数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/10/12 17:44
     */
    @RequestMapping("/pageBtDataViewListByCustomerId")
    public BaseResult pageBtDataViewListByCustomerId(SelectWatchVo selectWatchVo) {
        PageInfo<BtDataView> pageInfo = watchService.pageBtDataViewListByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @Description: TV获取单个用户体温曲线数据
     * @param customerId:
     * @param scope:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/20
     */
    @RequestMapping("/selectCustomerBtDataView")
    public BaseResult selectCustomerBtDataView(@RequestParam(required = true) String customerId,
                                               @RequestParam(required = true,defaultValue = "1")Integer scope) {
        return  BaseResult.ok(watchService.selectCustomerBtDataView(customerId,scope));
    }

    /**
     * @方法名：pageLocDataViewList
     * @描述： 查询-腕表定位数据-带分页
     * @作者： kjz
     * @日期： Created in 2020/9/11 18:12
     */
    @RequestMapping("/pageLocDataViewList")
    public BaseResult pageLocDataViewList(SelectWatchDataVo selectWatchDataVo) {
        PageInfo<LocDataView> pageInfo = watchService.pageLocDataViewList(selectWatchDataVo);
        return  BaseResult.ok(pageInfo);
    }


    /**
     * @方法名：pageLocDataViewListByCustomerId
     * @描述： 根据客户id查询该客户的历史定位信息
     * @作者： kjz
     * @日期： Created in 2020/10/13 14:57
     */
    @RequestMapping("/pageLocDataViewListByCustomerId")
    public BaseResult pageLocDataViewListByCustomerId(SelectWatchVo selectWatchVo) {
        PageInfo<LocDataView> pageInfo = watchService.pageLocDataViewListByCustomerId(selectWatchVo);
        return  BaseResult.ok(pageInfo);
    }

    /**
     * @方法名：selectLocDataViewByCustomerId
     * @描述： 根据客户id查询该客户的最新的定位信息
     * @作者： kjz
     * @日期： Created in 2020/10/23 16:58
     */
    @RequestMapping("/selectLocDataViewByCustomerId")
    public BaseResult selectLocDataViewByCustomerId(Integer customerId) {
        Object locDataView = watchService.selectLocDataViewByCustomerId(customerId);
        return  BaseResult.ok(locDataView);
    }

    /**
     * @方法名：selectLocDataListByCustomerId
     * @描述： 根据用户id查询运动轨迹
     * @作者： kjz
     * @日期： Created in 2020/9/23 16:30
     */
    @RequestMapping("/selectLocDataListByCustomerId")
    public BaseResult selectLocDataListByCustomerId(SelectLocDataVo selectLocDataVo){
        TrackView trackView = watchService.selectLocDataListByCustomerId(selectLocDataVo);
        return  BaseResult.ok(trackView);
    }

    /**
     * @Description: M99手表和来邦手表刷新定位
     * @param customerId:
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/10/19
     */
    @RequestMapping("/refreshWatchLoc")
    public BaseResult refreshWatchLoc(Integer customerId){
       return watchService.refreshWatchLoc(customerId);
    }


}
